//
//  GiftPageDataTool.m
//  MindBox
//
//  Created by MS on 16-1-8.
//  Copyright (c) 2016年 Lemon. All rights reserved.
//

#import "GiftPageDataTool.h"

@implementation GiftPageDataTool
/**
 *  获取最爱主界面数据
 */
+ (void)giftPageDataWithCat_id:(NSString *)cat_id Success:(void (^)(GiftPageData  * data))success
                       failure:(void (^)( NSError *error))failure
{
    NSString * url = GiftPage_URL(cat_id);
    
    [LGHttpTool GET:url parameters:nil success:^(id responseObject) {
        
        GiftPageModel * data = [GiftPageModel mj_objectWithKeyValues:responseObject];
        GiftPageData * giftdata = data.data;
        if (success) {
            
            success(giftdata);
        }
        
    } failure:^(NSError *error) {
        
        if (failure) {
            failure(error);
        }
    }];
    
}

/**
 *  获取热门精选数据
 */
+ (void)giftPage_Sel_DataWithCat_id:(NSString *)cat_id Success:(void (^)( NSArray * data))success failure:(void (^)( NSError *error))failure
{
    NSString * url = GiftPage_Sel_URL(cat_id);
    
    [LGHttpTool GET:url parameters:nil success:^(id responseObject) {
        
        GiftPage_Sel_Model * selData = [GiftPage_Sel_Model mj_objectWithKeyValues:responseObject];
        NSArray * data = selData.data;
        
        if (success) {
            
            success(data);
        }

        
    } failure:^(NSError *error) {
        if (failure) {
            failure(error);
        }

    }];
}

/**
 *  获取CollectionView商品数据
 */
+ (void)giftPage_ItemGoods_DataWithCat_id:(NSString *)cat_id seach_code:(NSString *)search_code pages:(int)pages Success:(void (^)( NSArray * data))success failure:(void (^)( NSError *error))failure
{
    NSString * url = GiftPage_Goods_URL(cat_id,search_code,pages);
    
    [LGHttpTool GET:url parameters:nil success:^(id responseObject) {
        
        Gift_Goods_Model * goodsData = [Gift_Goods_Model mj_objectWithKeyValues:responseObject];
        NSArray * data = goodsData.data;
        
        if (success) {
            
            success(data);
        }
        
    } failure:^(NSError *error) {
        if (failure) {
            failure(error);
        }
        
    }];

    
}
@end
